import { PiniaSymbol } from "./rootState";
import { ref } from "vue";

export let activePinia;
export function createPinia() {
  const state = ref({});
  const _p = []
  const pinia = {
    install(app) {
      // console.log("构建pinia");

      // vue2全局都可以获取
      // app.config.globalProperties.$pinia = pinia;

      // vue3可以通过inject获取
      app.provide(PiniaSymbol, pinia);
    },
    use(plugin) {
      _p.push(plugin);
    },
    state,
    _s: new Map(), // 存储所有的store
    _p,
  };
  
  activePinia = pinia;
  return pinia;
}
